package com.haha.keymap;

import javax.swing.*;
import java.awt.*;

public class SkillListRenderer extends JLabel implements ListCellRenderer<SkillConfig>{

    public SkillListRenderer() {
        setOpaque(true);
    }

    @Override
    public Component getListCellRendererComponent(JList<? extends SkillConfig> list, SkillConfig skill,
                                                  int index, boolean isSelected, boolean cellHasFocus) {

        setText(skill.toString());

        if (isSelected) {
            setBackground(list.getSelectionBackground());
            setForeground(list.getSelectionForeground());
        } else {
            setBackground(list.getBackground());
            setForeground(list.getForeground());
        }

        return this;
    }

}
